/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cgi.ndk.wf.service;

import com.cgi.ndk.wf.activiti.ActivitiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *
 * @author kovalcikm
 */
@Service
public class TaskServiceActiviti {

    @Autowired
    ActivitiService activitiService;

    public Object getAllTasks() {
        return activitiService.getAllTasks();
    }

    public Object getTaskDetail(String instanceId) {
        return activitiService.getTaskDetail(instanceId);
    }

    public Object changeTask(String instanceId, Object changeTask) {
        return activitiService.changeTask(instanceId, changeTask);
    }

    public Object complete(String instanceId) {
        class Complete {

            String action;

            public String getAction() {
                return action;
            }

            public void setAction(String action) {
                this.action = action;
            }
        }

        Complete complete = new Complete();
        complete.action = "complete";
        return activitiService.complete(instanceId, complete);
    }

    public Object claim(String instanceId, String user) {
        class Claim {

            String action;
            String assignee;

            public String getAction() {
                return action;
            }

            public void setAction(String action) {
                this.action = action;
            }

            public String getAssignee() {
                return assignee;
            }

            public void setAssignee(String assignee) {
                this.assignee = assignee;
            }

        }
        Claim claim = new Claim();
        claim.action = "claim";
        claim.assignee = user;
        return activitiService.claim(instanceId, claim);
    }

}
